package com.zjw.springhello;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/hello")
public class HelloController {

    @Resource
    private HttpServletResponse response;

    @GetMapping(path = "/hello",produces = {"application/json;charset=UTF-8"})
    public Map<String,String> hello() throws IOException {
        System.out.println("hello");
        Map<String,String> map=new HashMap<>();
        map.put("name","zjw");
//        response.setStatus(400);
//        response.setHeader("Content-type", "application/json;charset=UTF-8");
//        response.getWriter().write("{\"errMsg\":\"参数错误\"}");
//        response.sendError(513,"fkjdsfhjdshgfds");
        return map;
    }
}
